﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace PSU.Models
{
    public class RepositorioNivel: IRepositorio<Nivele>
    {
        private psuDBDataContext db = new psuDBDataContext();

        public IQueryable<Nivele> FindAll()
        {
            return db.Niveles;
        }

        public Nivele Get(int id)
        {
            return db.Niveles.SingleOrDefault(d => d.IdNivel == id);
        }

        public void Add(Nivele ob)
        {
            db.Niveles.InsertOnSubmit(ob);
        }

        public void Delete(Nivele ob)
        {
            db.Preguntas.DeleteAllOnSubmit(ob.Preguntas);
            db.Niveles.DeleteOnSubmit(ob);
        }

        public void Save()
        {
            db.SubmitChanges();
        }
    }
}